#ifndef ENCODINGDETECTOR_H
#define ENCODINGDETECTOR_H

#include "filemanager.h"
#include <wx/fontmap.h>
#include "nsUniversalDetector.h"

class wxString;

class EncodingDetector : public nsUniversalDetector {
  public:
    EncodingDetector( const wxString& filename, bool useLog = true );
    EncodingDetector( LoaderBase* fileLdr, bool useLog = true );
    EncodingDetector( const wxByte* buffer, size_t size, bool useLog = true );
    EncodingDetector( const EncodingDetector& rhs, bool useLog = true );
    ~EncodingDetector();
    bool IsOK() const;
    bool UsesBOM() const;
    int GetBOMSizeInBytes() const;
    wxFontEncoding GetFontEncoding() const;
    wxString GetWxStr() const;
  protected:
    bool DetectEncoding( const wxString& filename, bool convert_to_wxstring = true );
    bool DetectEncoding( const wxByte* buffer, size_t size, bool convert_to_wxstring = true );
    bool DetectEncodingEx( const wxByte* buffer, size_t len );
    void Report( const char* aCharset );
    bool m_IsOK;
    bool m_UseBOM;
    bool m_UseLog;
    int m_BOMSizeInBytes;
    wxFontEncoding m_Encoding;
  private:
    bool ConvertToWxString( const wxByte* buffer, size_t size );
    wxString m_MozillaResult;
    wxString m_ConvStr;
};

#endif
